from qqbot import QQBotSlot as qqbotslot, RunBot
import time


def onGroupMessage(bot, contact, member, content):
    print("[%s] <%s> %s" % (contact.name, member.name, content))


def onGroupMessage_alt(bot, contact, member, content):
    print("[%s] <%s> %s" % (contact.name, member.name, content))


if __name__ == '__main__':
    bot = RunBot()
    if 'onGroupMessage' in bot.slotsTable:  # 检查slot是否已存在
        print("Slot 'onGroupMessage' already exists. Using 'onGroupMessage_alt' instead.")
        # 删除已存在的slot（可选）
        del bot.slotsTable['onGroupMessage']
        # 添加新的slot
        bot.AddSlot(onGroupMessage_alt)
    else:
        # 添加新的slot
        bot.AddSlot(onGroupMessage)
    bot.login('1015575031', 'Novday2021')
    while True:
        try:
            bot.join()
        except KeyboardInterrupt:
            break
